#!/usr/bin/node

const http = require('http'),
      log = console.log,
      url = require('url');

var addr = process.argv[2] || 'http://sample.wangding.in/web/one-div.html';

var options = url.parse(global.encodeURI(addr));

http.get(options, (res) => {
  log(`HTTP/${res.httpVersion} ${res.statusCode} ${res.statusMessage}`);
  log('\n\n\n');

  let data = '';
  log(res.headers);
  log('\n\n\n');
  res.on('data', (chunck) => {
    data += chunck;
  });
  res.on('end', () => {
    log(data);
  });

});
